Format specifier will indicates that what type of data we requires to print on console Int - %d Float-%f Format specifiers Char-%c
Smallest unit in programming or an individual unit in programming are called “Token” A C program is a collection of tokens Tokens can be keyword, operator, and separator, constant and any other identifier. When we’re working with the token, we can’t break the token or we can’t split the token but s/w the tokens. We can give ‘n’ no of spaces, tabs and new lines
Eg: void main(){Pri ntf(“welcome”); } o/p: error | Void main{Printf(“welcome”); } o/p:welcome |
Printf-> to print anything on to the console Printf(“Hello”); Hello Printf(“****hello”); ***hello; Print(“%dwelcome%d”__ 10,20); error Function call mission(,) Printf(“%d welcome %d”,10,20); error Function call missing Printf(“%dwelcome %d”,10,20) error Statement mission(;) Printf(“@@@welcome###”); @@@welcome### Printf(“%d welcome %d”,10,20); 10 welcome20 Printf(“%d%d%d,10,20,30”); 102030 Printf(“%d %d %d”, 10,20,30); 10 20 30 Printf(“%d %d %d”,100,200,300); 100,200,300 Printf(“2+3=%d”,2+3); 2+3=5 Within the double quotes except format specifiers and special characters rest of all content will consider as characters only. Printf(“%d*%d=%d”,2,5); 2*5=10 Printf(“%d%d %d”,100,200); 100,200 gr/junk gr=garbage
In printf() statement, when we are passing an additional value which doesn’t contains correspondent format specifiers, then that value will be ignored
Total salary=25
Total salary=25000
Void main() { a=25 Printf(“a=%d”,a); } o/p= Error undefined symbol ‘a’ void main() { Int a; // declaration a=35; // Assigning Printf(“a=%d”,a); } o/p: a=35 Printf():- It is a pre-defined f’n, by using this f’n we can print the data on console.
You liked the article?
Like: 0
Vote for difficulty
Current difficulty (Avg): Medium
TekSlate is the best online training provider in delivering world-class IT skills to individuals and corporates from all parts of the globe. We are proven experts in accumulating every need of an IT skills upgrade aspirant and have delivered excellent services. We aim to bring you all the essentials to learn and master new technologies in the market with our articles, blogs, and videos. Build your career success with us, enhancing most in-demand skills in the market.